<?php
/**
 * Base_App
 *
 * LICENSE
 *
 * This source file is subject to the new CC-GNU LGPL
 * It is available through the world-wide-web at this URL:
 * http://creativecommons.org/licenses/LGPL/2.1/
 *
 * @category   Base_App
 * @copyright  Copyright (c) 2009 Alexander fanatique* Thomas (me@alexander-thomas.net)
 * @license    http://creativecommons.org/licenses/LGPL/2.1/
 */
class Base_App_Debug{
	/**
	* This is so we don’t have to keep typing Zend_Debug::dump($whatever)
	* @param mixed string|array|object
	* @return string
	*/
	public static function d($val){
		$env = null;
		if (Zend_Registry::isRegistered('environment')) {
	    	$env = Zend_Registry::get('environment');
		}
	
		if($env != 'production'){
			$backtrace = debug_backtrace();
			echo 	"<pre>",
						"Base_App_Debug::d()\n",
						"Called in ", $backtrace[1]["file"],"\n",
						"on line ", $backtrace[1]["line"],"\n",
					"</pre>";
			Zend_Debug::dump($val);	
		}
	}

	/**
	* dd is a shorthand function for "dump and die". It takes whatever you give it calle Zend_Dump, then dies.
	* Useful for debugging.
	* @param mixed string|array|object
	* @return string
	*/	
	public static function dd($val){
		$env = null;
		if (Zend_Registry::isRegistered('environment')) {
	    	$env = Zend_Registry::get('environment');
		}
		if($env != 'production'){
			self::d($val);	
			die();
		}
	}
}
?>
